<template>
  <div class="edu-page-warp">
    <el-breadcrumb separator="/"
                   style="margin-bottom:8px">
      <el-breadcrumb-item>异动类型设置</el-breadcrumb-item>
      <el-breadcrumb-item>异动类型维护</el-breadcrumb-item>
      <el-breadcrumb-item v-if="activeName == 'fields'">变更字段设置</el-breadcrumb-item>
      <el-breadcrumb-item v-else-if="activeName == 'field_auth'">字段权限设置</el-breadcrumb-item>
      <el-breadcrumb-item v-else-if="activeName == 'reason'">异动原因设置</el-breadcrumb-item>
    </el-breadcrumb>
    <ConditionCard
      :show-reset-btn="false"
      :show-search-btn="false"
      shadow="never"
      label-width="120px"
      label-position="right">
      <el-row :gutter="24"
              style="margin-top: 18px;">
        <el-col :span="8">
          
          <el-form-item :label="$t('abnormal.abnormalCategory')">
            <DictSelect
              v-model="queryForm.classCode"
              :data="options.classCodes"
              :clearable="false"
              disabled />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('abnormal.abnormalType')">
            <el-select
              v-model="queryForm.id"
              filterable
              style="width: 100%"
              disabled>
              <el-option
                v-for="item in options.typeCodes"
                :key="item.value"
                :label="item.label"
                :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('abnormal.allowStudentApply')">
            <DictSelect
              v-model="queryForm.studentApply"
              :data="options.studentApply"
              :clearable="false"
              disabled />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item :label="$t('label.trainingLevel')">
            <DictSelect
              :collapse-tags="false"
              :multiple="true"
              v-model="queryForm.trainingLevel"
              :data="options.trainingLevel"
              :clearable="false"
              disabled />
          </el-form-item>
        </el-col>
      </el-row>
    </ConditionCard>
    <el-card v-loading="loading"
             class="content-card"
             shadow="never">
      <el-tabs v-model="activeName"
               :before-leave="beforeLeave">
        <el-tab-pane
          :label="$t('abnormal.abnormalFieldSetting')"
          name="fields">
          <el-form v-if="isShow"
                   label-position="right"
                   label-width="90px">
            <el-row
              v-for="(abnormalField, index) in abnormalFields"
              :gutter="24"
              :key="abnormalField.id">
              <el-col :span="2">
                <div class="operate-wrap">
                  <i
                    class="el-icon-circle-plus"
                    @click="addAbnormalField(index)"></i>
                  <i
                    :class="{
                      'i-disabled':
                        abnormalFields.length === 1
                    }"
                    class="el-icon-remove"
                    @click="delAbnormalField(index)"></i>
                </div>
              </el-col>
              <el-col :span="6">
                <!--变更字段-->
                <el-form-item
                  :label="$t('abnormal.updateFields')">
                  <DictSelect
                    :plz-select="true"
                    :filterable="true"
                    v-model="abnormalField.fieldId"
                    :data="options.stuDicts"
                    :clearable="false"
                    style="width: 100%"
                    @change="
                      handlerStuDictChange(
                        abnormalField,
                        index
                      )
                    " />
                </el-form-item>
              </el-col>
              <el-col v-if="!!abnormalField.fieldId"
                      :span="6">
                <!--更新值-->
               
                <el-form-item
                  v-if="
                    abnormalField.type === 'select'  
                  "
                  :label="$t('abnormal.updatedValue')">
                  <el-select
                    v-if="abnormalField.fieldId == '68'"
                    v-model="abnormalField.value"
                    style="width:100%"
                    :clearable="false"
                    >
                    <el-option
                      v-for="item in options.statusProfession"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value" />
                  </el-select>
                  <DictSelect 
                    v-else
                    :plz-select="true"
                    v-model="abnormalField.value"
                    :data="abnormalField.options"
                    :clearable="false"
                    @change="valueChange(abnormalField.value,abnormalField.options,index)" />
                    
                </el-form-item>
                <el-form-item
                  v-if="abnormalField.type === 'querySelect'"
                  :label="$t('abnormal.updatedValue')">
                  <el-select
                    v-model="abnormalField.value"
                    :remote-method="getTeacher"
                    filterable
                    remote
                    :clearable="false"
                    style="width:100%"
                    @input="testClick">
                    <el-option
                      v-for="item in options.teachersList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value" />
                  </el-select>
                </el-form-item>
                <el-form-item
                  v-if="
                    abnormalField.type === 'input' ||
                      abnormalField.type === 'textarea'
                  "
                  :label="$t('abnormal.updatedValue')">
                  <el-input
                    v-model="abnormalField.value"
                    :clearable="false"
                    placeholder="请输入"
                    type="text"
                    style="width:100%"
                    @input="testClick" />
                </el-form-item>
                <el-form-item
                  v-if="abnormalField.type == 'date' || abnormalField.fieldId == '76' || abnormalField.fieldId == '75'"
                  :label="$t('abnormal.updateType')">
                  <DictSelect
                    :plz-select="true"
                    v-model="abnormalField.valueType"
                    :data="options.valueTypes"
                    :clearable="false"
                    @change="clearYear(abnormalField.value = '',abnormalField.fieldId)" />
                </el-form-item>
                <el-form-item
                  v-if="abnormalField.type == 'year' && abnormalField.fieldId != '76' && abnormalField.fieldId != '75'"
                  :label="$t('abnormal.updatedValue')">
                  <el-date-picker
                    v-model="abnormalField.value"
                    type="year"
                    style="width:100%"
                    placeholder="选择年级"
                    format="yyyy"
                    :clearable="false"
                    value-format="yyyy"
                    @input="gradeChange(abnormalField.value,abnormalField.options,index)"
                     />
                </el-form-item>
              </el-col>
              <el-col
                v-show="abnormalField.type === 'date' && abnormalField.fieldId != '83'"
                :span="6">
                <el-form-item
                  :label="$t('abnormal.updatedValue')">
                  <!--更新值-->
                  <DictSelect
                    v-if="
                      abnormalField.valueType === 'select'
                    "
                    :plz-select="true"
                    v-model="abnormalField.value"
                    :data="options.changeType"
                    :clearable="false" />
                    <DictSelect
                    v-if="
                      abnormalField.valueType === 'int' && abnormalField.fieldId == '92'
                    "
                    :plz-select="true"
                    v-model="abnormalField.value"
                    :data="options.changeDate"
                    :clearable="false" />
                  <el-date-picker
                    v-if="
                      abnormalField.valueType === 'int' && abnormalField.fieldId != '92'  
                    "
                    v-model="abnormalField.value"
                    format="yyyy-MM-dd"
                    type="date"
                    :clearable="false"
                    style="width:100%"
                    placeholder="选择日期"
                    @input="testClick" />
                </el-form-item>
              </el-col>
              <el-col
                v-show="abnormalField.valueType && (abnormalField.fieldId == '76' || abnormalField.fieldId == '75' || abnormalField.fieldId == '83')"
                :span="6">
                <el-form-item
                  :label="$t('abnormal.updatedValue')">
                  <!--更新值-->
                  <DictSelect
                    v-if="
                      abnormalField.valueType === 'select' && abnormalField.fieldId == '83'
                    "
                    :plz-select="true"
                    v-model="abnormalField.value"
                    :data="options.studyDate"
                    :clearable="false" />
                    <DictSelect
                    v-if="
                      abnormalField.valueType === 'select' && (abnormalField.fieldId == '76' || abnormalField.fieldId == '75')
                    "
                    :plz-select="true"
                    v-model="abnormalField.value"
                    :data="options.comeGrade"
                    @change="valueChange(abnormalField.value,abnormalField.options,index)" 
                    :clearable="false" />
                    <el-date-picker
                    v-if="
                      abnormalField.valueType === 'int'
                    "
                    v-model="abnormalField.value"
                    type="year"
                    style="width:100%"
                    placeholder="选择年级"
                    :clearable="false"
                    format="yyyy"
                    value-format="yyyy"
                    @input="gradeChange(abnormalField.value,abnormalField.options,index)"
                     />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-tab-pane>
        <el-tab-pane
          :label="$t('abnormal.abnormalFieldAuthSetting')"
          name="field_auth">
          <edu-table
            :pagination="false"
            :selection="false"
            :order="true"
            :data="fieldAuth.dataList"
            stripe
            style="width: 100%">
            <el-table-column
              :label="$t('abnormal.fieldName')"
              prop="fieldName" />
            <el-table-column :label="$t('abnormal.visiable')">
              <template slot-scope="props">
                <el-checkbox
                  v-model="props.row.visiable"
                  :true-label="1"
                  :false-label="0"
                  @change="
                    boxChange(
                      'visiable',
                      props.row,
                      props.$index
                    )
                  " />
              </template>
            </el-table-column>
            <el-table-column :label="$t('abnormal.studentUpdate')">
              <template slot-scope="props">
                <el-checkbox
                  v-model="props.row.studentUpdate"
                  :true-label="1"
                  :false-label="0"
                  @change="
                    boxChange(
                      'studentUpdate',
                      props.row,
                      props.$index
                    )
                  " />
              </template>
            </el-table-column>
            <el-table-column :label="$t('abnormal.facultyUpdate')">
              <template slot-scope="props">
                <el-checkbox
                  v-model="props.row.facultyUpdate"
                  :true-label="1"
                  :false-label="0"
                  @change="
                    boxChange(
                      'facultyUpdate',
                      props.row,
                      props.$index
                    )
                  " />
              </template>
            </el-table-column>
            <el-table-column :label="$t('abnormal.collegeUpdate')">
              <template slot-scope="props">
                <el-checkbox
                  v-model="props.row.collegeUpdate"
                  :true-label="1"
                  :false-label="0"
                  @change="
                    boxChange(
                      'collegeUpdate',
                      props.row,
                      props.$index
                    )
                  " />
              </template>
            </el-table-column>
            <el-table-column :label="$t('abnormal.required')">
              <template slot-scope="props">
                <el-checkbox
                  v-model="props.row.required"
                  :true-label="1"
                  :false-label="0"
                  @change="
                    boxChange(
                      'required',
                      props.row,
                      props.$index
                    )
                  " />
              </template>
            </el-table-column>
          </edu-table>
        </el-tab-pane>
        <el-tab-pane
          :label="$t('abnormal.abnormalReasonSetting')"
          name="reason">
          <div class="edu-opertion-bar">
            <div class="float-left">
              <el-button type="primary"
                         @click="addReason">
                {{ $t("abnormal.addReason") }}
              </el-button>
            </div>
          </div>
          <edu-table
            :pagination="false"
            :selection="false"
            :order="true"
            :data="reason.dataList"
            stripe
            style="width: 100%">
            <el-table-column :label="$t('abnormal.abnormalReason')">
              <template slot-scope="props">
                <el-input
                  v-model="props.row.reason"
                  type="text" />
              </template>
            </el-table-column>
            <el-table-column :label="$t('message.remark')">
              <template slot-scope="props">
                <el-input
                  v-model="props.row.remark"
                  type="text" />
              </template>
            </el-table-column>
            <el-table-column :label="$t('message.operating')">
              <template slot-scope="props">
                <el-button
                  type="text"
                  size="mini"
                  @click="deleteReason(props.$index)">{{ $t("message.delete") }}</el-button>
              </template>
            </el-table-column>
          </edu-table>
        </el-tab-pane>
      </el-tabs>
      <div class="footer">
        <el-button @click="back">{{ $t("message.return") }}</el-button>
        <el-button type="primary"
                   @click="save">
          {{ $t("message.save") }}
        </el-button>
      </div>
    </el-card>
    <edu-dialog
      ref="tipsDialog"
      title="提示"
      class="tip-item"
      @close="cancleDialog">
      {{ tipsDialog.tipsMsg }}
      <template slot="buttons">
        <el-button @click="handleDialog">取消</el-button>
        <el-button type="primary"
                   @click="handleDialog(1)">确定</el-button>
        <el-button type="primary"
                   @click="handleDialog(3)">保存并关闭</el-button>
      </template>
    </edu-dialog>
  </div>
</template>

<script>
import { findDirMaintenList } from 'common/src/api/culture/campusProfession';
import { findStatusProfessionList } from 'common/src/api/studentinfo'
import { queryDic } from 'common/src/api/dictionary';
import { queryZYFX } from 'common/src/api/dictionary';
import UTILS from 'common/src/utils/utils';
import { findTeacherList } from 'common/src/api/culture/change';
import * as API from 'common/src/api/abnormalType/abnormal';
import { yesOrNo } from 'common/src/filters/commonFilter';
export default {
    name: 'abnormal-type-setting',
    data() {
        return {
            count70: 0,
            count: 0,
            I: '',
            valuee: '',
            bound: 0,
            zyDel: false,
            originalFieldId: '',
            boundkey: '',
            value69: '',
            value62: '',
            value76: '',
            value96: '',
            value72: '',
            value248: '',
            XWLX: 0,
            NJ: 0,
            J: 0,
            M: 0,
            temp: '',
            isTrue: false,
            have96: false,
            // 当前激活的tab标签页
            activeName: 'fields',
            // 当前异动类型信息
            queryForm: {
                classCode: '',
                id: '', // 异动类型
                studentApply: '',
                trainingLevel: []
            },
            label: '',
            // el-select 的选项
            options: {
                // 异动大类
                classCodes: [],
                // 学籍专业
                statusProfession: [
                   
                ],
                // 异动类型
                typeCodes: [],
                // 所有异动字段
                stuDicts: [],
                // 是否学生可申请
                studentApply: [
                    {
                        value: 1,
                        label: this.$t('message.yes')
                    },
                    {
                        value: 0,
                        label: this.$t('message.no')
                    }
                ],
                // 异动生效时间
                changeType: [
                    {
                        value: '0',
                        label: this.$t('abnormal.accordingTime')
                    },
                    {
                        value: '1',
                        label: this.$t('abnormal.immediatelyChange')
                    }
                ],
                // 预计毕业时间
                changeDate: [],
                // 入学年级
                comeGrade:[],
                // 入学时间
                studyDate:[],
                // 是否是使用中
                inUse: [
                    {
                        value: 0,
                        label: this.$t('abnormal.notUsing')
                    },
                    {
                        value: 1,
                        label: this.$t('abnormal.using')
                    }
                ],
                // 培养层次
                trainingLevel: [],
                // 异动字段取值类型
                valueTypes: [
                    {
                        value: 'int',
                        label: this.$t('abnormal.input')
                    },
                    {
                        value: 'select',
                        label: this.$t('abnormal.autoValue')
                    }
                ],
                // 导师1/2
                teachersList: []
            },
            // 初始化的时候用来保存字段状态，用于在提交时判断哪些数据做了增删改
            originAbnormalFields: [],
            // 初始化的时候用来保存字段权限状态，用于在提交时判断哪些数据做了增删改
            originAbnormalFieldAuths: [],
            // 初始化的时候用来保存异动原因状态，用于在提交时判断哪些数据做了增删改
            originReasons: [],
            countt: 0,
            // 异动字段，用于渲染页面
            abnormalFields: [],
            isDelete: true,
            noXY: false,
            // 异动字段权限列表数据
            fieldAuth: {
                dataList: []
            },
            // 异动原因列表数据
            reason: {
                dataList: []
            },
            // 如果学籍字段是枚举类型。那么这个用来缓存请求得到的枚举数据。key是字段的type，value [{value: '',label}]类型
            stuDictCache: new Map(),
            tipsDialog: {
                tipsMsg: '',
                type: null,
                activeName: null, // 保存将要跳转的tab名称
                switchMode: 'normal' // 此参数用于区分模态框切换触发时机
                // normal :正常修改数据后返回触发模态框，tab:修改数据后切换页签触发模态框
            },
            needCheckData: true,
            currentIndex: 0, // 当前绑定值的index
            isShow: true // 时间选择器重新渲染
        };
    },
    created() {
        this.init();
    },
    methods: {
        // 获取当前绑定值的index
        // focusClick(index) {
        //     this.currentIndex = index;
        // },
        // 手动绑定当前值（解决双向绑定失效的问题）
        testClick(e) {
            this.isShow = false;
            // this.$set(this.abnormalFields[this.currentIndex], 'value', e);
            // this.abnormalFields[this.currentIndex]['value'] = e;
            this.isShow = true;
        },
        async getAllFields() {
          return await API.findStuDicts() 
        },
        // 根据异动类型id获取异动字段信息
        async getFieldsByTypeId() {
            return await API.getFieldsByTypeId(this.abnormalTypeId);
        },
        async getFieldsAuthByTypeId() {
          /*alert(this.abnormalTypeId)*/
            return await API.getFieldsAuthByTypeId(this.abnormalTypeId);
        },
        // 根据字典的key获取字典数据，在添加异动字段时，如果选中的异动字段是枚举类型，会根据value_属性去查找枚举的值并缓存在map中
        async queryDic(keys) {
            const data = {
                filter: {
                  /*degreeType: ['1'],*/
                  /*grade: 2020,*/
                  facultys: [this.value62]
                },
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys
            };

          for (let i = 0; i < this.abnormalFields.length; i++) {
            if (this.abnormalFields[i].fieldId == 62) {
              data.filter.facultys = [this.abnormalFields[i].value];
            }
          }

            for (let i = 0; i < this.abnormalFields.length; i++) {
              if (this.abnormalFields[i].fieldId == 76 && this.label === '本科') {
                data.filter.grade = this.abnormalFields[i].value;
              }
            }

            if (this.label == '研究生') {
              this.have96 = false;
              for (let i = 0; i < this.abnormalFields.length; i++) {
                if (this.abnormalFields[i].fieldId == 96) {
                  this.have96 = true;
                  data.filter.degreeType = this.abnormalFields[i].value;
                }
                if (this.abnormalFields[i].fieldId == 72) {
                  this.have96 = true;
                  data.filter.trainingLevel = this.abnormalFields[i].value;
                }
              }
            } ;
            if(keys.includes('G_ZY') && (!data.filter.grade || !data.filter.facultys) && this.label === '本科') {
                return
            }
             
                return await queryDic(data);
        },
        // 根据异动大类获取该大类下的所有异动类型
        getTypesByClassCode(val) {
            API.getAbnormalTypeByClassCode(val).then(res => {
                let { code, data } = res;
                if (code === 200) {
                    this.options.typeCodes = data;
                }
            });
        },
        clearYear(clear, fieldId) {
          if(fieldId == '76' && this.label === '本科') {
            this.abnormalFields.forEach(val=> {
              if(val.fieldId == 69) {
                val.value = ''
                val.options = []
              }
              if(val.fieldId == 68) {
                val.value = ''
                this.options.statusProfession = []
              }
            })
          }
          

        },
        init() {
            // 获取当前异动类型id
            this.abnormalTypeId = this.$route.params.id;
            // 获取异动大类列表、培养层次列表
            this.initOptions();
            // 获取所有异动字段字典
            this.getAllFields().then(res => {
                let { code, data } = res;
                if (code === 200) {
                    // console.log('数据字典:', data);
                    this.options.stuDicts = data
                        .filter(i => {
                            return i && i.type !== 'image' && i.id !== 67;
                        })
                        .map(i => ({
                            label: i.name,
                            value: i.id,
                            type: i.type,
                            value_: i.value
                        }));
                    // 导师1/2 type改为querySelect 做模糊查询
                    this.options.stuDicts.forEach((item) => {
                        if (item.value == 77 || item.value == 78) {
                            item.type = 'querySelect';
                        }
                    });
                }
                // 根据异动id获取异动详情
                this.getAbnormalDetailById(this.abnormalTypeId);
                // 初始化当前已设置的异动字段列表
                this.initFields();
                // 初始化当前已设置的异动字段权限列表
                this.initFieldAuth();
                // 初始化当前已设置的异动原因列表
                this.initReasons();
            });
            this.temp = '';
        },
        initOptions() {
            let keys = ['G_XJDL', 'X_PYCC', 'X_YD_YJBYSJ','X_YD_RXSJ','X_YD_RXNJ'];
            // 获取学籍状态和培养层次数据字典信息，用于在页面中显示异动类型信息
            this.queryDic(keys).then(res => {
                if (res.code === 200) {
                    UTILS.fillSelect(
                        {
                            classCodes: 'G_XJDL',
                            trainingLevel: 'X_PYCC',
                            changeDate: 'X_YD_YJBYSJ',
                            comeGrade: 'X_YD_RXNJ',
                            studyDate: 'X_YD_RXSJ'
                        },
                        res.data,
                        this.options
                    );
                    // 这时需要根据异动大类的code查询该大类下面所有异动类型
                }
            });
            
        },
        // 根据异动类型id获取异动类型信息
        getAbnormalDetailById(abonormalTypeId) {
          let _this = this
           let parm = {
                grade: '',
                statusFacultyList: [],
                trainingLevel: '',
                studentCategory: ''
            }
            API.getTypeDetailByTypeId(abonormalTypeId).then(res => {
                let { code, data } = res;
              // console.log(res);
              if (res.data.trainingLevel.indexOf('4') >= 0 || res.data.trainingLevel.indexOf('6') >= 0){
                this.label = '研究生'
              } else if (res.data.trainingLevel.indexOf('1')>=0){
                this.label = '本科'
              }

                // 学籍专业下拉数据 开始
                  _this.options.statusProfession = []
                  API.getFieldsByTypeId(_this.$route.params.id).then(resM => {
                      let { code, data } = resM;
                      if (code === 200) {
                        data.forEach(vals=> {
                          if(((vals.fieldId == 248 && this.label === '本科') || vals.fieldId == 62)&& vals.value) {
                            // 学籍学院
                            _this.value248 = vals.value
                            parm.statusFacultyList.push(vals.value)
                          }
                          if(vals.fieldId == 76 && vals.value && _this.label == '本科') {
                            // 当前年级
                            _this.value76 = vals.value
                            parm.grade = vals.value
                          }
                          if(vals.fieldId == 62 && vals.value) {
                            // 学院
                            _this.value62 = vals.value
                          }
                          if(vals.fieldId == 72 && _this.label == '研究生') {
                            // 培养层次
                            _this.value72 = vals.value
                            parm.trainingLevel = vals.value
                          } 
                            if(vals.fieldId == 96 && _this.label == '研究生') {
                              // 学位类型
                            parm.studentCategory = vals.value
                            _this.value96 = vals.value
                          }
                        })
                        if((_this.label == '本科' && _this.value76 && _this.value248) || (_this.label == '研究生' && _this.value96 && _this.value72 && _this.value248)) {
                          findStatusProfessionList(parm).then(resT=> {
                                if(resT.code === 200) {
                                    resT.data.forEach(val=> {
                                        _this.options.statusProfession.push(
                                            {
                                                label: val.professionName + '(' + val.professionCode + ')',
                                                value: val.statusProfessionCode
                                            }
                                        )
                                    })
                                }
                            })
                         }
                      }
                  });
                  // 学籍专业 结束
                if (code === 200) {
                    for (let key in this.queryForm) {
                        if (key == 'trainingLevel') {
                            this.queryForm[key] = data[key].split(',');
                        } else {
                            this.queryForm[key] = data[key];
                        }
                    }
                    this.getTypesByClassCode(this.queryForm.classCode);
                }
            });
            
        },
        // 初始化异动字段列表  XXXXXXXX
        initFields() {
            let initFieldsPromise = this.getFieldsByTypeId();
            initFieldsPromise.then(res => {
                let { code, data } = res;
                // console.log(data);
                if (code === 200) {
                    this.abnormalFields = data;
                    // 记录异动字段列表初始状态，用于提交时做对比，判断哪些字段是增删改的
                    this.originAbnormalFields = _.cloneDeep(data);
                    // console.log(this.originAbnormalFields)
                  this.originalField = this.originAbnormalFields
                    if (this.abnormalFields.length === 0) {
                        // 如果得到的是0条，那么就自动添加一条
                        this.addAbnormalField(-1, true);
                    } else {
                        // 把得到的异动字段转成页面可以渲染的格式，加了几个字段，在做判断时用到
                        this.abnormalFields.forEach(i => {
                            let stuDict = this.options.stuDicts.find(
                                e => e.value == i.fieldId
                            );
                            this.setAbnormalField(stuDict, i, true);
                        });
                    }
                }
            });
        },
        initFieldAuth() {
            let initFieldAuthPromise = this.getFieldsAuthByTypeId();
            initFieldAuthPromise.then(res => {
                let { code, data } = res;
                // console.log(res);
                if (code === 200) {
                    if (data.length > 0) {
                        this.fieldAuth.dataList = data;
                        this.originAbnormalFieldAuths = UTILS.clone(data);
                    }
                }
            });
        },
        initReasons() {
            API.getReasonsByTypeId(this.abnormalTypeId).then(res => {
                let { code, data } = res;
                if (code === 200) {
                    this.reason.dataList = data;
                    this.originReasons = UTILS.clone(data);
                }
            });
        },

        /*点击当前年级切换查询*/
        gradeChange(value,operation,index){
          this.isShow = false;
          // this.$set(this.abnormalFields[this.currentIndex], 'value', e);
          // this.abnormalFields[this.currentIndex]['value'] = e;
          this.isShow = true;

          if(this.abnormalFields[index].fieldId == 76){     
            if(this.abnormalFields[index].fieldId == 76) {
              this.value76 = this.abnormalFields[index].value;
            }    

            for (let ii = 0; ii < this.abnormalFields.length; ii++) {
              if (this.abnormalFields[ii].fieldId == 67 || this.abnormalFields[ii].fieldId == 68 || (this.abnormalFields[ii].fieldId == 69 && this.value76 && this.value62)){
                if(this.label === '本科' && this.abnormalFields[ii].fieldId == 68) {
                  this.abnormalFields[ii].value = ''
                  }   
                // 获取当前选中的学籍字段，主要是为了获取value_属性，用于页面上字段后面组件的渲染，控制显示select / input / date
                let stuDict = this.options.stuDicts.find(
                  i => i.value == this.abnormalFields[ii].fieldId
                );

                // 获取index，主要判断给条数据重新渲染
                let abnormarFieldInArray = this.abnormalFields[ii]
                  ? this.abnormalFields[ii]
                  : {};

                this.setAbnormalFieldPlus(stuDict, abnormarFieldInArray);
              } ;
            }
          }
              // 学籍专业下拉数据
              if(this.label == '本科') {
              this.options.statusProfession = []
              let parm = {
                grade: this.value76,
                statusFacultyList: []
              }
                  if(this.value248) {
                    parm.statusFacultyList.push(this.value248)
                  }
                  if(this.value76 && this.value248) {
                  findStatusProfessionList(parm).then(res=> {
                  if(res.code === 200) {
                      res.data.forEach(val=> {
                          this.options.statusProfession.push(
                              {
                                  label: val.professionName + '(' + val.professionCode + ')',
                                  value: val.statusProfessionCode
                              }
                          )
                      })
                  }
              })
            }
          }
        },
         

        valueChange(value, operation,index) {
          if(this.abnormalFields[index].fieldId == 76 && this.label == '本科') {
            this.options.statusProfession = []
            for (let i = 0; i < this.abnormalFields.length; i++) {
                    if(this.abnormalFields[i].fieldId == 68) {
                      this.abnormalFields[i].value = ''
                    }
                  }

          }
            // console.log(value);
            // console.log(operation);
            this.valuee = value; /* 14025*/
            // console.log('valuee值为：' + this.valuee);
            // console.log(this.abnormalFields);
            for (let i = 0; i < this.abnormalFields.length; i++) {
                if (this.abnormalFields[i].value == '' && this.abnormalFields[i].fieldId == 70) {
                    this.abnormalFields.splice(i, 1);
                }
                if(this.abnormalFields[i].fieldId == 76) {
                  this.value76 = this.abnormalFields[i].value
                }
                if(this.abnormalFields[i].fieldId == 96) {
                  this.value96 = this.abnormalFields[i].value
                }
                if(this.abnormalFields[i].fieldId == 72) {
                  this.value72 = this.abnormalFields[i].value
                }
                if((this.abnormalFields[i].fieldId == 62) || (this.abnormalFields[i].fieldId == 248 && this.label == "本科") ) {
                  this.value248 = this.abnormalFields[i].value
                  this.value62 = this.abnormalFields[i].value
                }
                // if(this.abnormalFields[i].fieldId == 68) {
                //   this.abnormalFields[i].value = ''
                //   }
            }
                if((this.abnormalFields[index].fieldId == 248 && this.label == "本科") || ((this.abnormalFields[index].fieldId == 62 || this.abnormalFields[index].fieldId == 72 || this.abnormalFields[index].fieldId == 96) && this.label == "研究生")) {
                  // 重置学籍专业下拉数据
                  for (let i = 0; i < this.abnormalFields.length; i++) {
                    if(this.abnormalFields[i].fieldId == 68) {
                      this.abnormalFields[i].value = ''
                    }
                  }
                  this.options.statusProfession = []
                  let parm = {
                            grade: '',
                            statusFacultyList: [],
                            trainingLevel: '',
                            studentCategory: ''
                        }
                        if(this.value248) {
                          parm.statusFacultyList.push(this.value248)
                        } 
                         if(this.value76 && this.label == '本科') {
                          parm.grade = this.value76
                        } 
                         if(this.value72 && this.label == '研究生') {
                          this.$set(parm,'trainingLevel',this.value72)
                        } 
                         if(this.value96 && this.label == '研究生') {
                          parm.studentCategory = this.value96
                        }

                  
                        if((this.label == '本科' && this.value76 && this.value248) || (this.label == '研究生' && this.value96 && this.value72 && this.value248)) {
                        findStatusProfessionList(parm).then(res=> {
                        if(res.code === 200) {
                            res.data.forEach(val=> {
                                this.options.statusProfession.push(
                                    {
                                        label: val.professionName + '(' + val.professionCode + ')',
                                        value: val.statusProfessionCode
                                    }
                                )
                            })
                        }
                    })
                  }
                }

        if(this.abnormalFields[index].fieldId == 62 || (this.label === '研究生' && (this.abnormalFields[index].fieldId == 96 || this.abnormalFields[index].fieldId == 72)) || (this.label === '本科' && (this.abnormalFields[index].fieldId == 76))){             /*点击学院切换查询*/
          for (let ii = 0; ii < this.abnormalFields.length; ii++) {
            /*debugger*/
            if (this.abnormalFields[ii].fieldId == 67 || 
            (this.label === '本科' && this.value76 && this.value62 && (this.abnormalFields[ii].fieldId == 69)) ||
            (this.label === '研究生'  && this.value62 && this.value72 && this.value96 && (this.abnormalFields[ii].fieldId == 69))
            ){
              // 获取当前选中的学籍字段，主要是为了获取value_属性，用于页面上字段后面组件的渲染，控制显示select / input / date
              let stuDict = this.options.stuDicts.find(
                i => i.value == this.abnormalFields[ii].fieldId
              );
              // 获取index，主要判断给条数据重新渲染
              let abnormarFieldInArray = this.abnormalFields[ii]
                ? this.abnormalFields[ii]
                : {};
              this.setAbnormalFieldPlus(stuDict, abnormarFieldInArray);
            } ;
          }
          
        }

          /*// 获取当前选中的学籍字段，主要是为了获取value_属性，用于页面上字段后面组件的渲染，控制显示select / input / date
          let stuDict = this.options.stuDicts.find(
            i => i.value == abnormalField.fieldId
          );

          // 获取index，主要判断给条数据重新渲染
          let abnormarFieldInArray = this.abnormalFields[index]
            ? this.abnormalFields[index]
            : {};

          this.setAbnormalField(stuDict, abnormarFieldInArray);*/


        },
        // delNext(delField) {
        //   // 删除级联下级
        //   for (let i = 0; i < this.abnormalFields.length; i++) {
        //         // 删除 学籍专业、培养专业
        //         if (this.abnormalFields[i].fieldId == delField) {
        //           this.abnormalFields.splice(i, 1);
        //         }
        //     }
        // },
        // 学籍字段下拉框数据变化时回调
        handlerStuDictChange(abnormalField, index) {
          // if(abnormalField.fieldId == '62') {
          //   this.abnormalFields.forEach(val=> {
          //     if(val.fieldId == 69) {
          //       val.value = ''
          //       val.options = []
                 
          //     }
          //   })
          // }
          let xy = false   // 学院
          let dqnj = false  // 当前年级
          let xjxy = false  // 学籍学院
          let pycc = false  // 培养层次
          let xwlx = false  // 学位类型
          let delField = '' // 被删除的Field
          let temp68 = false  // 学籍专业
          let temp69 = false  // 培养专业
          for(let i = 0; i<this.abnormalFields.length; i++) {
            if(this.abnormalFields[i].fieldId == 62) {
                xy = true
            } 
            if(this.abnormalFields[i].fieldId == 248) {
                xjxy = true
            } 
            if(this.abnormalFields[i].fieldId == 72) {
                pycc = true
            } 
            if(this.abnormalFields[i].fieldId == 96) {
                xwlx = true
            } 
            if(this.abnormalFields[i].fieldId == 76) {
                dqnj = true
            }
            if(this.abnormalFields[i].fieldId == 68) {
                temp68 = true
            }
            if(this.abnormalFields[i].fieldId == 69) {
                temp69 = true
            }
          }

          if(this.label === '本科' && this.abnormalFields.length > 1) {
              // 本科生变更当前年级后 同时删除级联下级 学籍专业、培养专业
                if (temp68 && (!xjxy || !dqnj)){
                  this.abnormalFields.forEach(val=> {
                    if(val.fieldId == 68) {
                      val.value = ''
                      this.options.statusProfession = []
                    }
                  })
                }  
                if (temp69 && (!xy || !dqnj)){
                  this.abnormalFields.forEach(val=> {
                    if(val.fieldId == 69) {
                      val.value = ''
                      val.options = []
                    }
                  })
                } 
            } else if(this.label === '研究生' && this.abnormalFields.length > 1) {
              // 研究生变更培养层次、学位类型后 同时删除级联下级 学籍专业、培养专业
               if (temp68 && (!xy || !pycc || !xwlx)){
                  this.abnormalFields.forEach(val=> {
                    if(val.fieldId == 68) {
                      val.value = ''
                      this.options.statusProfession = []
                    }
                  })
                }  
                if (temp69 && (!xy || !pycc || !xwlx)){
                  this.abnormalFields.forEach(val=> {
                    if(val.fieldId == 69) {
                      val.value = ''
                      val.options = []
                    }
                  })
                } 
            }

            
             


          /*有专业没学院*/
          this.noXY = false;
          for (let i = 0; i < this.abnormalFields.length; i++) {
            if (this.abnormalFields[i].fieldId == 67 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 69) {

              for (let j = 0; j < this.abnormalFields.length; j++) {
                if (this.abnormalFields[j].fieldId == 62){
                  this.noXY = true;
                } ;
              }

            }
          }

          // if(this.label === '本科' && abnormalField.fieldId == 68 ) {
          //       this.options.statusProfession = []
          //       let parm = {
          //           grade: this.value76,
          //           statusFacultyList: []
          //       }
          //       if(this.value248) {
          //         parm.statusFacultyList.push(this.value248)
          //       }
          //       findStatusProfessionList(parm).then(res=> {
          //       if(res.code === 200) {
          //           res.data.forEach(val=> {
          //               this.options.statusProfession.push(
          //                   {
          //                       label: val.professionName + '(' + val.professionCode + ')',
          //                       value: val.professionCode
          //                   }
          //               )
          //           })
          //       }
          //   })
          // }

          if(this.originalField[index]) {

            let initFieldsPromise = this.getFieldsByTypeId();
            initFieldsPromise.then(res => {
              let { code, data } = res;
              // console.log(data);

              /*data.forEach(i => {
                let stuDict = this.options.stuDicts.find(
                  e => e.value == i.fieldId
                );
                this.setAbnormalField(stuDict, i, true);
              });*/

              if (code === 200) {
                // 记录异动字段列表初始状态，用于提交时做对比，判断哪些字段是增删改的
                this.originAbnormalFields = _.cloneDeep(data);
                this.originalField = this.originAbnormalFields
              }
            })

            this.originalFieldId = this.originalField[index].fieldId
          };

          if (!this.noXY && this.label == '研究生'){
            for (let i = 0; i < this.abnormalFields.length; i++) {
              if (this.abnormalFields[i].fieldId == 67 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 69) {
                if (this.abnormalFields.length > 1) {
                  this.abnormalFields.splice(i, 1);
                  return this.$message.warning('请先添加学院');
                }else {
                  this.abnormalFields[index].fieldId = this.originalFieldId;
                  return this.$message.warning('请先添加学院');
                }
              }
            }
          } ;
          // 放开必填选项 lsfangc

            if (abnormalField.fieldId == 70) {
                this.bound = 1;
                for(let i = 0; i < this.abnormalFields.length; i++) {
                    if (this.abnormalFields[i].fieldId == 69) {
                        ++this.count70;
                    }
                }
                if (this.count70 == 0) {
                  /*debugger*/
                    this.$message.warning('请先添加培养专业');
                    /*this.abnormalFields.splice(index, 1);*/
                    this.abnormalFields[index].fieldId = this.originalFieldId;

                  /*let stuDict = this.options.stuDicts.find(
                    e => e.value === this.originalFieldId
                  );*/
                  let stuDict = {};
                  for(let i = 0 ; i < this.options.stuDicts.length ; i++){
                    if (this.options.stuDicts[i].value === this.originalFieldId){
                      stuDict = this.options.stuDicts[i];
                    } ;
                  }
                  this.setAbnormalField(stuDict, { fieldId: this.originalFieldId }, true);
                    this.count70 = 0;
                    /*return;*/
                }
            }

            if (abnormalField.fieldId == 69) {
                this.count = 0;
                for(let i = 0; i < this.abnormalFields.length; i++) {
                    if (this.abnormalFields[i].fieldId == 69) {
                        ++this.count;
                    }
                }
                if (this.count > 1) {
                    this.$message.warning('培养专业已存在，不能重复添加');
                    this.count = 0;
                    this.abnormalFields.splice(index, 1);
                    return;
                }
            }
            if (abnormalField.fieldId == 70) {
                this.bound = 1;
                this.isTrue = false;
                for(let i = 0; i < this.abnormalFields.length; i++) {
                    if (this.abnormalFields[i].fieldId == 69) {
                        this.I = i;
                        this.isTrue = true;
                    }
                }
                if (!this.isTrue) {

                  /*let stuDict = this.options.stuDicts.find(
                    e => e.value === this.originalFieldId
                  );*/
                  let stuDict = {};
                  for(let i = 0 ; i < this.options.stuDicts.length ; i++){
                    if (this.options.stuDicts[i].value === this.originalFieldId){
                      stuDict = this.options.stuDicts[i];
                    } ;
                  }
                  this.setAbnormalField(stuDict, { fieldId: this.originalFieldId }, true);

                    this.$message.warning('请先添加培养专业');
                    this.isTrue = false;
                    /*return;*/
                } else {
                    // console.log('培养专业更新值：' + this.valuee);
                    if (this.valuee !== '' || this.abnormalFields[this.I].value !== '') {

                    } 
                    // else {
                    //     // console.log(this.abnormalFields);
                    //     for (let i = 0; i < this.abnormalFields.length; i++) {
                    //         if (this.abnormalFields[i].value == '' && this.abnormalFields[i].fieldId == 70) {
                    //             this.abnormalFields.splice(i, 1);
                    //         }
                    //     }
                    //     this.$message.warning('培养专业更新值不能为空');
                    //     return;
                    // }
                }
            }
            if (abnormalField.fieldId == 70) {
                this.bound = 1;
                for (let i = 0; i < this.abnormalFields.length; i++) {
                    if (this.abnormalFields[i].fieldId == 69) {
                        this.value69 = this.abnormalFields[i].value;
                    }
                }
            }

            if(abnormalField.fieldId == 67 || abnormalField.fieldId == 68 || abnormalField.fieldId == 69 || abnormalField.fieldId == 72){
              this.J = 0 ;
              this.value62 = '';
              /////////////////////
              this.NJ = 0 ;
              this.value76 = '';

              this.XWLX = 0;
              this.value96 = '';

              this.PYCC = 0;
              this.value72 = '';

              this.M = 0 ;
              this.value248 = ''

              for (let i = 0; i < this.abnormalFields.length; i++) {
                if (this.abnormalFields[i].fieldId == 62) {
                  // console.log(this.abnormalFields[i].value);
                  this.value62 = this.abnormalFields[i].value;        /*是否有学院*/
                  ++this.J
                }
              }

              if (this.J == 0 && this.label === '本科' && abnormalField.fieldId == 69){
                if(this.abnormalFields.length > 1) {
                  this.abnormalFields.splice(index, 1);
                } else {
                  this.abnormalFields[index].fieldId = this.originalFieldId;
                } 
                this.$message.warning('请先添加学院');
                return;
              } ;

              for (let i = 0; i < this.abnormalFields.length; i++) {
                if (this.abnormalFields[i].fieldId == 248) {
                  // console.log(this.abnormalFields[i].value);
                  this.value248 = this.abnormalFields[i].value;        /*是否有学籍学院*/
                  ++this.M
                }
              }
              if (this.M == 0 && this.label === '本科' && abnormalField.fieldId == 68){
                if(this.abnormalFields.length > 1) {
                  this.abnormalFields.splice(index, 1);
                } else {
                  this.abnormalFields[index].fieldId = this.originalFieldId;
                }
                this.$message.warning('请先添加学籍学院');
                return;
              } ;
              // 放开必填选项 lsfangc



              // if (this.value62 == ''){
              //   for (let i = 0; i < this.abnormalFields.length; i++) {
              //     if (this.abnormalFields[i].value == '' && (this.abnormalFields[i].fieldId == 69 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 67)) {
              //       this.abnormalFields.splice(i, 1);
              //     }
              //   }
              //   this.$message.warning('学院更新值不能为空');
              //   return;
              // } ;
              // 放开必填选项 lsfangc

              //此处校验当前年级
              if(this.label === '本科') {
              for (let i = 0; i < this.abnormalFields.length; i++) {
                if (this.abnormalFields[i].fieldId == 76) {
                  // console.log(this.abnormalFields[i].value);
                  this.value76 = this.abnormalFields[i].value;        /*是否有年级*/
                  ++this.NJ
                }
              }

              if (this.NJ == 0 ){
                this.$message.warning('请先添加当前年级');
                if(this.abnormalFields.length > 1) {
                  this.abnormalFields.splice(index, 1);
                } else {
                  this.abnormalFields.splice(index, 1);
                  this.addAbnormalField()
                }
                
                return;
              } ;
            }
              // 放开必填选项 lsfangc

              // if (this.value76 == ''){
              //   for (let i = 0; i < this.abnormalFields.length; i++) {
              //     if (this.abnormalFields[i].value == '' && (this.abnormalFields[i].fieldId == 69 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 67)) {
              //       this.abnormalFields.splice(i, 1);
              //     }
              //   }
              //   this.$message.warning('当前年级更新值不能为空');
              //   return;
              // } ;
              // 放开必填选项 lsfangc

              
              if (this.label == '研究生'){
                //此处校验学位类型
                for (let i = 0; i < this.abnormalFields.length; i++) {
                  if (this.abnormalFields[i].fieldId == 96) {
                    // console.log(this.abnormalFields[i].value);
                    this.value96 = this.abnormalFields[i].value;        /*是否有年级*/
                    ++this.XWLX
                  }
                }

                if (this.XWLX == 0){  
                if(this.abnormalFields.length > 1) {
                  this.abnormalFields.splice(index, 1);
                  return this.$message.warning('请先添加学位类型');
                }
                 
                 
                } ;
                // 放开必填选项 lsfangc

                // if (this.value96 == ''){
                //   for (let i = 0; i < this.abnormalFields.length; i++) {
                //     if (this.abnormalFields[i].value == '' && (this.abnormalFields[i].fieldId == 69 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 67)) {
                //       this.abnormalFields.splice(i, 1);
                //     }
                //   }
                //   this.$message.warning('学位类型更新值不能为空');
                //   return;
                // } ;
                // 放开必填选项 lsfangc

                for (let i = 0; i < this.abnormalFields.length; i++) {
                if (this.abnormalFields[i].fieldId == 72) {
                  // console.log(this.abnormalFields[i].value);
                  this.value72 = this.abnormalFields[i].value;        /*是否有年级*/
                  ++this.PYCC
                }
              }
              if (this.PYCC == 0){
                this.$message.warning('请先添加培养层次');
                this.abnormalFields.splice(index, 1);
                return;
              } ;
              } ;
            }

            // 获取当前选中的学籍字段，主要是为了获取value_属性，用于页面上字段后面组件的渲染，控制显示select / input / date
            let stuDict = this.options.stuDicts.find(
                i => i.value == abnormalField.fieldId
            );
            // 获取index，主要判断给条数据重新渲染
            let abnormarFieldInArray = this.abnormalFields[index]
                ? this.abnormalFields[index]
                : {};
            // let abnormalFieldAuthInArray = this.fieldAuth.dataList[index]?this.fieldAuth.dataList[index]:{};
            // abnormalFieldAuthInArray.fieldName = stuDict.label;
            // abnormalFieldAuthInArray.fieldId = stuDict.value;
            // 调用渲染数据函数，告诉把哪条数据渲染成什么样


            this.setAbnormalField(stuDict, abnormarFieldInArray);

            // this.setAbnormalFieldAuth(abnormalFieldAuthInArray, index);
            // abnormalField.type === stuDict.type;
        },
        query(key) {
            return new Promise(resolve => {
                // console.log(key);
                /* debugger;*/
               /*alert(this.bound);*/
               if(key != 'X_FX'){
                 this.bound = 0;
               }
               if( key && (key.indexOf('0') >= 0 ||
                 key.indexOf('1') >= 0 ||
                 key.indexOf('2') >= 0 ||
                 key.indexOf('3') >= 0 ||
                 key.indexOf('4') >= 0 ||
                 key.indexOf('5') >= 0 ||
                 key.indexOf('6') >= 0 ||
                 key.indexOf('7') >= 0 ||
                 key.indexOf('8') >= 0 ||
                 key.indexOf('9') >= 0)){
                 this.bound = 1
               }
                if(this.bound == 1) {
                    /*this.boundkey = key;*/
                   /*alert('培养专业code:' + key);*/
                    queryZYFX(key).then(res => {
                        // console.log(res);
                        /* res.data*/
                        resolve(res);
                      this.boundkey = Object.keys(res.data)[0];
                    });
                    this.bound = 0;
                } else {
                    this.queryDic([key]).then(res => {
                        // console.log(res);
                        resolve(res);
                    });
                }
            });
            /* return new Promise(resolve => {
              findDirMaintenList({
                grade: 2020,
                keyword: "",
                pageNum_: 1,
                pageSize_: 100,
                professionCode: this.value69,
                total_: 0
              }).then(res => {
                    resolve(res);
                    console.log(res)
              })
            })*/
        },
        // 获取导师1/2下拉数据
        getTeacher(e) {
            findTeacherList({ keyWord: e }).then(res => {
                if (res.code == 200) {
                    this.options.teachersList = [];
                    let opts = [];
                    opts = res.data.map((item) => {
                        return {
                            label: item.name + '(' + item.code + ')',
                            value: item.code
                        };
                    });
                    this.options.teachersList = opts;
                } else {
                    throw res.code;
                }
            });
        },
        // 作用：当异动字段页面的字段删除时也要给字段权限列表删除字段
        // setAbnormalFieldAuth(abnormalAuth, index) {
        //     this.fieldAuth.dataList.splice(index, 1, abnormalAuth);
        // },
        // 渲染数据函数，告诉把哪条数据渲染成什么样
        async setAbnormalField(
            stuDict,
            abnormarFieldInArray,
            flagInit = false
        ) {
          /*debugger*/
          let fieldType = stuDict && stuDict.type;
          let key = stuDict && stuDict.value_;
          /*alert(key);*/
          if (stuDict.value === 69){
            this.temp = abnormarFieldInArray.value
          } ;
          if (stuDict.value === 70){
            this.bound = 1;
          } ;

          if (!key) {
            if (this.value69 && this.value69 !== '') {
              key = this.value69;
            }
            if (this.temp !== ''){
              key = this.temp;
            } ;

          }
            // 设置类型，如果是单选，根据key获取数据字典数据渲染成el-select,见页面部分
            abnormarFieldInArray.type = fieldType;

            // console.log(stuDict);
            // console.log(fieldType);
            // console.log(key);

            if (fieldType === 'select' && key) {
              /*debugger*/
                /*if (this.stuDictCache.has(key)) {
                    abnormarFieldInArray.options = this.stuDictCache.get(key);
                } else {*/
                    let { code, data } = await this.query(key);
                    if (code === 200) {
                        // console.log(typeof key);
                        /*debugger*/
                      if (key) {
                        if (key.indexOf('0') >= 0 ||
                            key.indexOf('1') >= 0 ||
                            key.indexOf('2') >= 0 ||
                            key.indexOf('3') >= 0 ||
                            key.indexOf('4') >= 0 ||
                            key.indexOf('5') >= 0 ||
                            key.indexOf('6') >= 0 ||
                            key.indexOf('7') >= 0 ||
                            key.indexOf('8') >= 0 ||
                            key.indexOf('9') >= 0
                        ) {
                          key = this.boundkey;
                          /* key = this.boundkey;*/
                          /*alert(key)*/
                          this.bound = 1;
                        }
                      }
                      if (data[key]){
                          let opts = Object.keys(data[key]).map(i => ({
                              value: i,
                              label: data[key][i]
                          }));
                          this.stuDictCache.set(key, opts);
                          this.$set(abnormarFieldInArray, 'options', opts);
                      } ;
                    }
                /*}*/
                // 当选的异动字段变化时，将值清空。。如果是初始化调用了这个函数，不清空，显示初始化的数据
                abnormarFieldInArray.value = flagInit
                    ? abnormarFieldInArray.value
                    : '';
            } else if (fieldType === 'date' || abnormarFieldInArray.fieldId == '75' || abnormarFieldInArray.fieldId == '76' ) {
                this.$set(
                    abnormarFieldInArray,
                    'valueType',
                    flagInit
                        ? abnormarFieldInArray.valueType
                        : this.options.valueTypes[0].value
                );
                abnormarFieldInArray.value = flagInit
                    ? abnormarFieldInArray.value
                    : '';
            } else if (fieldType === 'querySelect') {
                this.getTeacher(abnormarFieldInArray.value);
            } else {
                abnormarFieldInArray.value = flagInit
                    ? abnormarFieldInArray.value
                    : '';
            }
        },
      // 渲染数据函数，告诉把哪条数据渲染成什么样
      async setAbnormalFieldPlus(     //用来改变学院时对应的专业接口调用
        stuDict,
        abnormarFieldInArray,
        flagInit = false
      ) {
        /*debugger*/
        let fieldType = stuDict && stuDict.type;
        let key = stuDict && stuDict.value_;
        if (stuDict.value === 69){
          this.temp = abnormarFieldInArray.value
        } ;
        if (stuDict.value === 70){
          this.bound = 1;
        } ;

        if (!key) {
          if (this.value69 && this.value69 !== '') {
            key = this.value69;
          }
          if (this.temp !== ''){
            key = this.temp;
          } ;

        }
        // 设置类型，如果是单选，根据key获取数据字典数据渲染成el-select,见页面部分
        abnormarFieldInArray.type = fieldType;
        // console.log(stuDict);
        // console.log(fieldType);
        // console.log(key);

        if (fieldType === 'select' && key) {
          /*debugger*/
          /*if (this.stuDictCache.has(key)) {
            abnormarFieldInArray.options = this.stuDictCache.get(key);
          } else {*/
            let { code, data } = await this.query(key);
            if (code === 200) {
              // console.log(typeof key);
              /*debugger*/
              if (key) {
                if (key.indexOf('0') >= 0 ||
                    key.indexOf('1') >= 0 ||
                    key.indexOf('2') >= 0 ||
                    key.indexOf('3') >= 0 ||
                    key.indexOf('4') >= 0 ||
                    key.indexOf('5') >= 0 ||
                    key.indexOf('6') >= 0 ||
                    key.indexOf('7') >= 0 ||
                    key.indexOf('8') >= 0 ||
                    key.indexOf('9') >= 0
                ) {
                  key = this.boundkey;
                  /* key = this.boundkey;*/
                  /*alert(key)*/
                  this.bound = 1;
                }
              }
              if (data[key]){
                let opts = Object.keys(data[key]).map(i => ({
                  value: i,
                  label: data[key][i]
                }));
                this.stuDictCache.set(key, opts);
                this.$set(abnormarFieldInArray, 'options', opts);
              } ;
            }
          /*}*/
          // 当选的异动字段变化时，将值清空。。如果是初始化调用了这个函数，不清空，显示初始化的数据
          abnormarFieldInArray.value = flagInit
            ? abnormarFieldInArray.value
            : '';
        } else if (fieldType === 'date' || abnormarFieldInArray.fieldId == '75' || abnormarFieldInArray.fieldId == '76') {
          this.$set(
            abnormarFieldInArray,
            'valueType',
            flagInit
              ? abnormarFieldInArray.valueType
              : this.options.valueTypes[0].value
          );
          abnormarFieldInArray.value = flagInit
            ? abnormarFieldInArray.value
            : '';
        } else if (fieldType === 'querySelect') {
          this.getTeacher(abnormarFieldInArray.value);
        } else {
          abnormarFieldInArray.value = flagInit
            ? abnormarFieldInArray.value
            : '';
        }
      },
        // 页面中加号图标点击时的回调
        addAbnormalField(index) {
            // 新增一条数据，字段id默认取字段列表的第一个的value
            let newAbnormalType = { fieldId: '' };
            // 根据这个value的类型加不同的属性，页面根据这个属性显示
            this.setAbnormalField({}, newAbnormalType);/*this.options.stuDicts[0]*/

            // 将这条数据添加到abnormalFields中，页面中就多了一条异动字段信息
            this.abnormalFields.splice(index + 1, 0, newAbnormalType);

            /*this.originAbnormalFields = _.cloneDeep(this.abnormalFields);*/

            /*alert('长度:' + this.abnormalFields.length);*/
        },
        // 异动字段tab中减号图标点击回调
        delAbnormalField(index) {
          this.countt = 0 ;
          /*let len = this.abnormalFields.length - 1*/
          // 当只有一条数据时不让删除
            if (this.abnormalFields.length === 1) {
              return;
            } 

            if (this.abnormalFields.length === 2 && this.abnormalFields[index].fieldId == 62){
              let temp = this.abnormalFields.filter(o => (o.fieldId == 67 || o.fieldId == 68 || o.fieldId == 69));
              if ( temp == []){
                this.abnormalFields.splice(index, 1);
              };
            }

            // if(this.label === '本科') {
            //   // 本科生删除当前年级后 同时删除级联下级 学籍专业、培养专业
            //   if(this.abnormalFields.length > 1 && this.abnormalFields[index].fieldId == 76) {
            //     let temp = this.abnormalFields.filter(o => (o.fieldId == 68 || o.fieldId == 69));
            //     if ( temp == []){
            //       this.abnormalFields.splice(index, 1);
            //     } else {
            //       this.zyDel = true;
            //     }
            //   } else if(this.abnormalFields.length > 1 && this.abnormalFields[index].fieldId == 248) {
            //     // 删除学籍学院，同时删除级联下级 学籍专业
            //     let temp = this.abnormalFields.filter(o => (o.fieldId == 68));
            //       if ( temp == []){
            //       this.abnormalFields.splice(index, 1);
            //     } else {
            //         for (let i = this.abnormalFields.length - 1; i >= 0; i--) {
            //         if (this.abnormalFields[i]) {
            //           // 删除 学籍专业
            //           if (this.abnormalFields[i].fieldId == 68) {
            //             this.abnormalFields.splice(i, 1);
            //           }
            //         }
            //       }
            //     }
            //   }
            // } else if(this.label === '研究生') {
            //   // 研究生删除培养层次、学位类型后 同时删除级联下级 学籍专业、培养专业
            //   if(this.abnormalFields.length > 1 && (this.abnormalFields[index].fieldId == 72 || this.abnormalFields[index].fieldId == 96)) {
            //     let temp = this.abnormalFields.filter(o => (o.fieldId == 68 || o.fieldId == 69));
            //     if ( temp == []){
            //       this.abnormalFields.splice(index, 1);
            //     } else {
            //       this.zyDel = true;
            //     }
            //   }
            // }

            // // 删除级联下级
            // if(this.zyDel) {
            // for (let i = this.abnormalFields.length - 1; i >= 0; i--) {
            //     if (this.abnormalFields[i]) {
            //       // 删除 学籍专业、培养专业
            //       if (this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 69) {
            //         this.abnormalFields.splice(i, 1);
            //       }
            //     }
            //   }
            // }

          this.noXY = false;
          for (let i = 0; i < this.abnormalFields.length; i++) {
            if (this.abnormalFields[i].fieldId == 67 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 69) {

              for (let j = 0; j < this.abnormalFields.length; j++) {
                if (this.abnormalFields[index].fieldId == 62){
                  this.noXY = true;
                } ;
              }

            }
          };

          for (let i = 0; i < this.abnormalFields.length; i++) {
            if (this.abnormalFields[i].fieldId == 62 || this.abnormalFields[i].fieldId == 67 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 69 || this.abnormalFields[i].fieldId == 70){
              ++this.countt
            } ;
          }
          if (this.countt == this.abnormalFields.length){
            this.noXY = false;
            this.isDelete = false;
          } ;
          if (this.noXY){
              for (let i = this.abnormalFields.length - 1; i >= 0; i--) {
                if (this.abnormalFields[i]) {
                  if (this.abnormalFields[i].fieldId == 67 || this.abnormalFields[i].fieldId == 68 || this.abnormalFields[i].fieldId == 69 || this.abnormalFields[i].fieldId == 70) {
                    this.abnormalFields.splice(i, 1);
                  }
                }
              }
              this.countt = 0 ;
          } ;

          if (this.abnormalFields[index].fieldId != 62 || this.abnormalFields[index].fieldId != 67 || this.abnormalFields[index].fieldId != 68 || this.abnormalFields[index].fieldId != 69 ) {
            this.isDelete = true;
          }


          /*len = this.abnormalFields.length - 1;*/
            /*for (let i = 0; i < this.abnormalFields.length; i++) {
                if (this.abnormalFields[i].fieldId == 70 && this.abnormalFields[index].fieldId == 69) {
                    this.$message.warning('请先删除专业方向名称');
                    return;
                }
            }*/
          if (this.abnormalFields[index]) {
            if (this.abnormalFields[index].fieldId == 69) {
            for (let ii = this.abnormalFields.length - 1; ii >= 0; ii--) {
                  if (this.abnormalFields[ii].fieldId == 69 || this.abnormalFields[ii].fieldId == 70) {
                    this.abnormalFields.splice(ii, 1);
                    this.isDelete = false;
                  }
                }
            }
          }

            if (this.abnormalFields[index].fieldId == 69 && this.abnormalFields[index].value !== '') {
                this.valuee = '';
            }


            // 异动字段列表删除
            if (this.isDelete) {
              this.abnormalFields.splice(index, 1);

            }
            this.isDelete = true;
            // console.log(this.abnormalFields);
            /*this.originAbnormalFields = _.cloneDeep(this.abnormalFields);*/
            // 异动字段权限列表删除
            this.deleteAbnormalFieldAuth(index);

            /*alert('长度:' + this.abnormalFields.length);*/
        },
        // 异动字段权限列表删除数据函数
        deleteAbnormalFieldAuth(index) {
            this.fieldAuth.dataList.splice(index, 1);
        },
        // 异动字段权限列表添加数据函数
        // addAbnormalFieldAuth(index, fieldAuth) {
        //     this.fieldAuth.dataList.splice(index + 1, 0, fieldAuth);
        // },
        /**
         * params { mode:visiable,studentUpdate,facultyUpdate,collegeUpdate,required}
         * params {data 当前操作的哪一组数据}
         * params {index 当前操作的数组index}
         */
        boxChange(mode, data, index) {
            let list = _.cloneDeep(this.fieldAuth.dataList);
            let obj = list[index];
            if (mode == 'required') {
                if (obj['required']) {
                    obj['visiable'] = 1;
                }
            } else if (mode == 'visiable') {
                if (!obj[mode]) {
                    obj['required'] = 0;
                    obj['studentUpdate'] = 0;
                    obj['facultyUpdate'] = 0;
                    obj['collegeUpdate'] = 0;
                }
            } else {
                if (obj[mode]) {
                    obj['visiable'] = 1;
                }
            }
            list[index] = obj;
            this.$set(this.fieldAuth, 'dataList', list);
        },
        /**
         *  { fields:变更字段为空校验; field_auth:字段权限设置为空校验； reason：异动原因为空校验}
         * 保存数据并做空参数校验
         */
       save() {

          let xy = false   // 学院
          let dqnj = false  // 当前年级
          let xjxy = false  // 学籍学院
          let pycc = false  // 培养层次
          let xwlx = false  // 学位类型
          let delField = '' // 被删除的Field
          let temp68 = false  // 学籍专业
          let temp69 = false  // 培养专业
          for(let i = 0; i<this.abnormalFields.length; i++) {
            if(this.abnormalFields[i].fieldId == 62) {
                xy = true
            } 
            if(this.abnormalFields[i].fieldId == 248) {
                xjxy = true
            } 
            if(this.abnormalFields[i].fieldId == 72) {
                pycc = true
            } 
            if(this.abnormalFields[i].fieldId == 96) {
                xwlx = true
            } 
            if(this.abnormalFields[i].fieldId == 76) {
                dqnj = true
            }
            if(this.abnormalFields[i].fieldId == 68) {
                temp68 = true
            }
            if(this.abnormalFields[i].fieldId == 69) {
                temp69 = true
            }
          }

          if(this.label === '本科') {
              // 本科生变更当前年级后 同时删除级联下级 学籍专业、培养专业
                if (temp68){
                  if(!xjxy) {
                    this.$message.error('请添加学籍学院')
                    return
                  } else if(!dqnj) {
                    this.$message.error('请添加当前年级')
                    return
                  }
                }  
                if (temp69){
                  if(!xy) {
                    this.$message.error('请添加学院')
                    return
                  } else if(!dqnj) {
                    this.$message.error('请添加当前年级')
                    return
                  }
                } 
            } else if(this.label === '研究生') {
              // 研究生变更培养层次、学位类型后 同时删除级联下级 学籍专业、培养专业
               if (temp68){
                  if(!xy) {
                    this.$message.error('请添加学院')
                    return
                  } else if(!pycc) {
                    this.$message.error('请添加培养层次')
                    return
                  } else if(!xwlx) {
                    this.$message.error('请添加学位类型')
                    return
                  }
                }  
                if (temp69){
                  if(!xy) {
                    this.$message.error('请添加学院')
                    return
                  } else if(!pycc) {
                    this.$message.error('请添加培养层次')
                    return
                  } else if(!xwlx) {
                    this.$message.error('请添加学位类型')
                    return
                  }
                } 
            }


          for (let i = 0; i < this.abnormalFields.length; i++) {
            if (this.abnormalFields[i].fieldId == 70) {
             this.isTT = true
            }
          }
          if(this.isTT) {
            for (let i = 0; i < this.abnormalFields.length; i++) {
              if (this.abnormalFields[i].fieldId == 69) {
                this.isTT = false
              }
            }
          }
          if (this.isTT){
            for (let i = 0; i < this.abnormalFields.length; i++) {
              if (this.abnormalFields[i].fieldId == 70) {
                /*this.abnormalFields.splice(i, 1);*/
              }
            }
            this.$message.warning('培养专业不能为空');
            return;
          } ;

           if (this.activeName === 'fields') {
                this.abnormalFields.forEach(a => {
                    if (!a.fieldId) {
                        this.showMessage('warning', '变更字段不能为空');
                        throw 'err';
                    }
                });

                 this.saveFields(); // 保存变更字段设置
            } else if (this.activeName === 'field_auth') {
                // this.fieldAuth.dataList.forEach(f => {
                //     if (
                //         !f.collegeUpdate &&
                //         !f.facultyUpdate &&
                //         !f.required &&
                //         !f.studentUpdate &&
                //         !f.visiable
                //     ) {
                //         this.showMessage(
                //             "warning",
                //             "字段权限设置每行至少勾选一列"
                //         );
                //         throw "err";
                //     }
                // });
                this.saveFieldAuth(); // 保存字段权限设置
            } else if (this.activeName === 'reason') {
                // if (this.reason.dataList.length == 0) {
                //     this.showMessage("warning", "异动原因设置至少填写一行");
                //     return;
                // } else {
                //     this.reason.dataList.forEach(r => {
                //         if (!r.reason) {
                //             this.showMessage("warning", "异动原因有空白行，请填写内容或删除对应行");
                //             throw "err";
                //         }
                //     });
                // }
                this.reason.dataList.forEach(r => {
                    if (!r.reason) {
                        this.showMessage('warning', '异动原因有空白行，请填写内容或删除对应行');
                        throw 'err';
                    }
                });
                this.saveReason(); // 保存异动原因设置
            }
        },
        saveFields() {
            // 先保存字段列表
            let updateFieldsPromise = this.updateFields();
            updateFieldsPromise.then(resT => {
                if (resT.code === 200) {
                    // 获取字段权限信息
                    let initFieldAuthPromise = this.getFieldsAuthByTypeId();
                    initFieldAuthPromise.then(res => {

                    /*for (let i = 0 ; i < res.data.length ; i++){
                      for (let j = i+1 ; j < res.data.length ; j++){
                        if ( res.data[i].fieldId = res.data[j].fieldId){
                          res.data.splice(i,1)
                        }
                      } ;
                    }*/

                    let { code, data } = res;
                      // console.log(res)



                        if (code === 200 && data.length > 0) {
                            this.originAbnormalFieldAuths = UTILS.clone(data);
                        }
                        this.initFields();
                        // 重新获取异动字段权限信息
                        this.initFieldAuth();
                    });
                    this.showMessage('success', this.$t('message.saveSuccess'));
                } else {
                    this.showMessage('error', '不能存在相同的变更字段');
                    return
                }
            }) 
        },
        saveFieldAuth() {
            let updateFieldsPromise = this.updateFields();
            updateFieldsPromise.then(res => {
                if (res.code === 200) {
                    // 获取字段权限信息
                    let initFieldAuthPromise = this.getFieldsAuthByTypeId();
                    initFieldAuthPromise.then(resT => {
                        let { code, data, msg } = resT;
                        if (code === 200 && data.length > 0) {
                            this.originAbnormalFieldAuths = UTILS.clone(data);
                        }
                        // 保存字段权限信息
                        let updateFieldsAuthPromise = this.updateFieldsAuth();
                        updateFieldsAuthPromise.then(resM => {
                            if (resM.code === 200) {
                                this.showMessage(
                                    'success',
                                    this.$t('message.saveSuccess')
                                );
                            }
                            // 重新获取异动字段信息
                            this.initFields();
                            // 重新获取异动字段权限信息
                            this.initFieldAuth();
                        });
                    });
                } else {
                    this.showMessage('error', res.msg);
                }
            });
        },
        saveReason() {
            let updateReasonsPromise = this.updateReasons();
            updateReasonsPromise.then(res => {
                let { code, msg } = res;
                if (res.code === 200) {
                    this.showMessage('success', this.$t('message.saveSuccess'));
                    this.initReasons();
                } else {
                    this.showMessage('error', msg);
                }
            });
        },
        async updateFields() {
            // 需要判断所有字段的fieldid不能重复
          /*console.log(this.abnormalFields)*/
          /*for (let i = this.originAbnormalFields.length - 1 ; i >= 0 ; i--){
            if (this.originAbnormalFields[i].fieldId == ''){
              this.originAbnormalFields.splice(i,1)
            }
          } ;*/

            let abnormalFields = this.abnormalFields.map(i => ({
                id: i.id,
                typeId: this.abnormalTypeId,
                fieldId: i.fieldId,
                value: i.value,
                valueType: i.valueType
            }));
            // 数组id去重
            let uniqueAbnormalFieldIds = new Set(
                abnormalFields.map(i => i.fieldId)
            );
            if (uniqueAbnormalFieldIds.size < abnormalFields.length) {
                return { code: 300, msg: this.$t('abnormal.duplicateFields') };
            }
            // let addAbnormalFields = abnormalFields.filter(i => !i.id);
            let addAbnormalFields = abnormalFields.filter(i => {
                return (
                    !this.originAbnormalFields.some(
                        o => o.fieldId == i.fieldId
                    ) || !i.id
                );
            });
            // console.log(this.originAbnormalFields);
            // console.log(this.abnormalFields);
            let deleteAbnormalFields = this.originAbnormalFields.filter(i => {
                return (
                    !this.abnormalFields.some(field => i.id == field.id) ||
                    !this.abnormalFields.some(a => a.fieldId == i.fieldId)
                );
            });
            let updateFields = abnormalFields.filter(i => {
                let field = this.originAbnormalFields.find(f => f.id === i.id);
                if (!field) {
                    return false;
                }

                return (
                    field.fieldId != i.fieldId ||
                    field.value != i.value ||
                    field.valueType != i.valueType
                );
            });
            let params = [
                {
                    operateType: 1,
                    list: deleteAbnormalFields
                },
                {
                    operateType: 2,
                    list: addAbnormalFields
                },
                {
                    operateType: 3,
                    list: updateFields
                }
            ];
            // console.log('用来更新的参数：', params);
            return await API.updateFields(params);
        },
        async updateFieldsAuth() {
            let updateFieldAuths = this.fieldAuth.dataList.filter(i => {
                let fieldAuth = this.originAbnormalFieldAuths.find(
                    e => e.typeId === i.typeId && e.fieldId === i.fieldId
                );
                return !(
                    fieldAuth.visiable === i.visiable &&
                    fieldAuth.studentUpdate === i.studentUpdate &&
                    fieldAuth.facultyUpdate === i.facultyUpdate &&
                    fieldAuth.collegeUpdate === i.collegeUpdate &&
                    fieldAuth.required === i.required
                );
            });
            if (updateFieldAuths.length > 0) {
                return await API.updateFieldAuths(updateFieldAuths);
            }
            return { code: 200 };
        },
        async updateReasons() {
            // 判断是不是存在重复数据
            let uniqueReasons = new Set(
                this.reason.dataList.map(i => i.reason)
            );
            if (uniqueReasons.size < this.reason.dataList.length) {
                return { code: 300, msg: this.$t('abnormal.duplicateFields') };
            }
            let addReasons = this.reason.dataList.filter(i => !i.id);
            let deleteReasons = this.originReasons.filter(i => {
                return !this.reason.dataList.some(reason => i.id == reason.id);
            });
            let updateReasons = this.reason.dataList.filter(i => {
                let reason = this.originReasons.find(r => r.id === i.id);
                if (!reason) {
                    return false;
                }
                return !(
                    reason.reason === i.reason && reason.remark === i.remark
                );
            });
            let params = [
                {
                    operateType: 1,
                    list: deleteReasons
                },
                {
                    operateType: 2,
                    list: addReasons
                },
                {
                    operateType: 3,
                    list: updateReasons
                }
            ];
            return await API.updateReasons(params);
        },
        addReason() {
            this.reason.dataList.push({
                typeId: this.abnormalTypeId
            });
        },
        deleteReason(index) {
            this.reason.dataList.splice(index, 1);
        },
        showMessage(type, message) {
            this.$message({ type, message });
        },
        back() {
            let isBack = this.isModfiyOrAdd(this.activeName, 'back');
            if (isBack) {
                this.backTypeList();
            }
        },
        backTypeList() {
            this.$store.commit('delete_tabs', this.$route.path);
            this.$router.go(-1);
        },
        submit() {
            // 先保存异动字段
            let updateFieldsPromise = this.updateFields();
            updateFieldsPromise.then(res => {
                if (res.code === 200) {
                    // 获取字段权限信息
                    let initFieldAuthPromise = this.getFieldsAuthByTypeId();
                    initFieldAuthPromise.then(res => {
                        let { code, data } = res;
                        if (code === 200 && data.length > 0) {
                            this.originAbnormalFieldAuths = UTILS.clone(data);
                        }
                        // 保存异动字段权限
                        let updateFieldsAuthPromise = this.updateFieldsAuth();
                        let updateReasonsPromise = this.updateReasons();
                        Promise.all([
                            updateFieldsAuthPromise,
                            updateReasonsPromise
                        ]).then(res => {
                            let [res1, res2] = res;
                            if (res1.code === 200 && res2.code === 200) {
                                // 提交完成，跳转到列表页
                                this.$router.push({
                                    name: 'abnormalTypeList'
                                });
                            } else {
                                let message;
                                if (res2.code != 200) {
                                    message = res2.msg;
                                }
                                if (res1.code != 200) {
                                    message = res1.msg;
                                }
                                this.showMessage('error', message);
                            }
                        });
                    });
                }
            });
        },
        // 处理tab点击事件
        beforeLeave(activeName, oldActiveName) {
            this.tipsDialog.switchMode = 'tab';
            this.activeName = oldActiveName;
            this.tipsDialog.activeName = activeName;
            // 调用方法  isModfiyOrAdd 判断页签切换时，数据是否存在修改
            // isModfiyOrAdd 回调结果   false:修改；true:未修改
            return this.needCheckData
                ? this.isModfiyOrAdd(oldActiveName, 'tab')
                : true;
        },
        /*
         * 判断数据是否有修改项或者新增项
         * active 跳转之前的tab名称
         * clickType tab:页签之间切换；back:点击返回按钮
         */
        isModfiyOrAdd(active, clickType) {
            let origin = [];


            let fresh = [];
            if (active === 'fields') {
                origin = this.originAbnormalFields;
                fresh = this.abnormalFields;
            } else if (active === 'field_auth') {
                origin = this.originAbnormalFieldAuths;
                fresh = this.fieldAuth.dataList;
                this.initFields();
            } else if (active === 'reason') {
                origin = this.originReasons;
                fresh = this.reason.dataList;
                this.initFields();
            }
            if (fresh.length > origin.length) {
                this.showDialog(clickType);
                return false;
            } else {
                let arr = origin.map(item => {
                    return fresh.some(fieldItem => {
                        if (active === 'fields') {
                            return (
                                fieldItem.id === item.id &&
                                fieldItem.fieldId === item.fieldId &&
                                fieldItem.value === item.value
                            );
                        } else if (active === 'field_auth') {
                            return (
                                fieldItem.id === item.id &&
                                fieldItem.fieldId === item.fieldId &&
                                fieldItem.collegeUpdate ===
                                    item.collegeUpdate &&
                                fieldItem.facultyUpdate ===
                                    item.facultyUpdate &&
                                fieldItem.required === item.required &&
                                fieldItem.studentUpdate ===
                                    item.studentUpdate &&
                                fieldItem.visiable === item.visiable
                            );
                        } else if (active === 'reason') {
                            return (
                                fieldItem.id === item.id &&
                                fieldItem.remark === item.remark &&
                                fieldItem.reason === item.reason
                            );
                        }
                    });
                });
                if (arr.some(arrItem => !arrItem)) {
                    this.showDialog(clickType);
                    return false;
                } else {
                    return true;
                }
            }
        },
        // 弹窗提示
        showDialog(clickType) {
            if (clickType === 'tab') {
                this.tipsDialog.tipsMsg =
                    '切换页签将不会保存当前设置，是否确定？';
            } else if (clickType === 'back') {
                this.tipsDialog.tipsMsg = '返回将不会保存当前设置，是否确定？';
            }
            this.$refs.tipsDialog.open();
        },
        /**
         * params {type 不传、空值：取消，1：确定，3：保存并关闭}
         * 先判断模态框的触发按钮  tab or  normal
         * tab type 空值：关闭提示框不切换页签，1：不保存，切换页签 ，3：切换页签并保存
         * normal type 空值:关闭并返回列表，1不保存返回列表，3：保存信息并返回列表
         */
        handleDialog(type = 0) {
            this.$refs.tipsDialog.close();
            if (this.tipsDialog.switchMode == 'tab') {
                if (type == 1) {
                    this.needCheckData = false;
                    this.activeName = this.tipsDialog.activeName;
                    // 切换页签，点击确定没有保存时，回复页面初始数据
                    const data = _.cloneDeep(this.originAbnormalFields);
                    // console.log(data)
                    data.forEach(i => {
                        let stuDict = this.options.stuDicts.find(
                            e => e.value == i.fieldId
                        );
                        this.setAbnormalField(stuDict, i, true);
                    });
                    this.abnormalFields = data;
                    this.fieldAuth.dataList = _.cloneDeep(
                        this.originAbnormalFieldAuths
                    );
                    this.reason.dataList = _.cloneDeep(this.originReasons);
                } else if (type == 3) {
                    this.save();
                    this.needCheckData = false;
                    this.activeName = this.tipsDialog.activeName;
                }
            } else {
                if (type == 1) {
                    this.backTypeList();
                } else if (type == 3) {
                    this.save();
                    this.backTypeList();
                }
            }
            setTimeout(() => {
                this.needCheckData = true;
            }, 0);
        },
        cancleDialog() {
            this.$refs.tipsDialog.close();
        }
    }
};
</script>
<style lang="scss" scoped>
$bottom: 64px;
.edu-page-warp {
    height: 100%;
}
.content-card {
    padding: 0 24px $bottom 24px;
    margin-bottom: 24px;
    position: relative;
    // min-height: calc(100% - 200px);
}
.edu-page-title {
    span {
        line-height: 24px;
        display: inline-block;
        padding-right: 10px;
        font-size: 18px;
        font-weight: bold;
        color: #2b3b4e;
    }
}
.operate-wrap {
    display: flex;
    justify-content: space-around;
    margin-top: 6px;
    i {
        font-size: 20px;
        color: #409eff;
    }
    .i-disabled {
        color: #a5a5a5;
    }
}
.footer {
    position: absolute;
    text-align: right;
    border-top: 1px solid #ddd;
    bottom: 0;
    height: $bottom;
    line-height: $bottom;
    right: 0;
    width: 100%;
    padding-right: 24px;
}
</style>
